#include<iostream>
#include<cstring>
#include<string>
using namespace std;
const int N = 1e5 + 10;
typedef long long LL;
int n, m;
int arr[N];
int cnt[11][N];
int main()
{
	cin >> n >> m;
	for (int i = 0; i < n; i++) {
		cin >> arr[i];
	}
	for (int i = 0; i < n; i++) {
		LL t = arr[i] % m;
		for (int j = 0; j < 11; j++) {
			cnt[j][t]++;
			t = t * 10 % m;
		}
	}
	LL ans = 0;
	for (int i = 0; i < n; i++) {
		LL t = arr[i] % m;
		int len = to_string(arr[i]).size();
		ans += cnt[len][(m - t) % m];
		LL r = t;
		while (len--) {
			t = t * 10 % m;
		}
		if (r == (m - t) % m) {
			ans--;
		}
	}
	cout << ans << endl;
	return 0;
}